<template>
	<view class="my">
		<template v-if="globalJSON">
			<template v-if="isLogin">
				<template v-if="userDetail">
					<view
						class="user-top"
						:style="userDetail.banner?'background: url('+userDetail.banner+') no-repeat;background-size: 100%;':globalJSON.userCenter.topStyle">
						<view class="user-detail">
							<view class="user-detail-top">
								<view class="_avatar">
									<image :src="userDetail.avatar" mode="widthFix"></image>
								</view>
								<view class="_center">
									<view class="_nickname">{{userDetail.nickname}}</view>
									<view class="_user-count">
										<view class="_for">
											{{userDetail.stats.likerCount}}<text>{{userDetail.interaction.likeName}}</text>
										</view>
										<view class="_for">
											{{userDetail.stats.followerCount}}<text>{{userDetail.interaction.followName}}</text>
										</view>
										<view class="_for">
											{{userDetail.stats.postPublishCount}}<text>帖子</text>
										</view>
									</view>
								</view>
							</view>
						</view>
						<view class="user-bio" v-if="userDetail.bio">{{userDetail.bio}}</view>
					</view>
					<view class="user-operate-box-horizontal">
						<view class="_for" @click="avatarBox = true">
							<text class="iconfont icon-user"></text>
							<text class="text">{{$t('modifyAvatar')}}</text>
						</view>
						<view class="_for" @click="nicknameBox = true">
							<text class="iconfont icon-image-text"></text>
							<text class="text">{{$t('modifyNickname')}}</text>
						</view>
						<view class="_for" @click="bannerBox = true">
							<text class="iconfont icon-yingyuan"></text>
							<text class="text">{{$t('modifyBanner')}}</text>
						</view>
						<view class="_for" @click="clickGenderButton">
							<text class="iconfont icon-nan" v-if="userDetail.gender === 2"></text>
							<text class="iconfont icon-nv" v-if="userDetail.gender === 3"></text>
							<text class="iconfont icon-bangzhu" v-if="userDetail.gender === 1"></text>
							<text class="text">{{$t('modifyGender')}}</text>
						</view>
						<view class="_for" @click="$_to('pages/accountSettings')">
							<text class="iconfont icon-huiyuan"></text>
							<text class="text">{{$t('modifyBirthday')}}</text>
						</view>
						<view class="_for" @click="bioBox = true">
							<text class="iconfont icon-paihangbang"></text>
							<text class="text">{{$t('modifyBio')}}</text>
						</view>
						<view class="_for" @click="locationBox = true">
							<text class="iconfont icon-map"></text>
							<text class="text">{{$t('modifyLocation')}}</text>
						</view>
						<view class="_for" @click="$_to('pages/accountSettings')">
							<text class="iconfont icon-shezhi"></text>
							<text class="text">账号设置</text>
						</view>
					</view>
					
					<view class="user-operate-box-vertical">
						<!-- <view
							v-if="globalJSON.isUserBusinessCard"
							class="_for"
							@click="$_to('my/userBusinessCard')">
							<text class="iconfont icon-fuzhi" style="color: #ff705f;"></text>
							<view class="_for-c">
								<text class="text">我的名片</text>
							</view>
							<text class="iconfont icon-arrow-double-right"></text>
						</view> -->
						<view class="_for" @click="$_to('my/post')">
							<text class="iconfont icon-liebiao" style="color: #00c5c7;"></text>
							<view class="_for-c">
								<text class="text">{{$t('myPost')}}</text>
							</view>
							<text class="iconfont icon-arrow-double-right"></text>
						</view>
						<view class="_for" @click="$_to('draft/draft')">
							<text class="iconfont icon-yingpingmoban" style="color: #ff5073;"></text>
							<view class="_for-c">
								<text class="text">{{$t('postDraft')}}</text>
							</view>
							<text class="iconfont icon-arrow-double-right"></text>
						</view>
						<view class="_for" @click="$_to('my/comment')">
							<text class="iconfont icon-pinglun" style="color: #ff5073;"></text>
							<view class="_for-c">
								<text class="text">{{$t('myComment')}}</text>
							</view>
							<text class="iconfont icon-arrow-double-right"></text>
						</view>
						<view class="_for" @click="$_to('my/followPost')">
							<text class="iconfont icon-shoucang" style="color: #43be49;"></text>
							<view class="_for-c">
								<text class="text">我收藏的帖子</text>
							</view>
							<text class="iconfont icon-arrow-double-right"></text>
						</view>
						<view class="_for" @click="$_to('my/followUser')">
							<text class="iconfont icon-user" style="color: #53bcf3;"></text>
							<view class="_for-c">
								<text class="text">我关注的人</text>
							</view>
							<text class="iconfont icon-arrow-double-right"></text>
						</view>
					</view>
					<view class="user-operate-box-vertical">
						<view
							class="_for"
							@click="clickConversationPolicyButton">
							<text class="iconfont icon-shequ" style="color: #53bcf3;"></text>
							<view class="_for-c">
								<text class="text">对话设置</text>
								<text
									class="_text"
									v-if="userDetail.conversationPolicy == 1">
									[所有人]
								</text>
								<text
									class="_text"
									v-else-if="userDetail.conversationPolicy == 2">
									[你关注的人]
								</text>
								<text
									class="_text"
									v-else-if="userDetail.conversationPolicy == 3">
									[你关注的人和已认证的人]
								</text>
								<text
									class="_text"
									v-else>
									[不允许所有人]
								</text>
							</view>
							<text class="iconfont icon-arrow-double-right"></text>
						</view>
						<view
							class="_for"
							@click="clickCommentPolicyButton">
							<text class="iconfont icon-taolunqu" style="color: #a09989;"></text>
							<view class="_for-c">
								<text class="text">评论设置</text>
								<text
									class="_text"
									v-if="userDetail.commentPolicy == 1">
									[所有人]
								</text>
								<text
									class="_text"
									v-else-if="userDetail.commentPolicy == 2">
									[你关注的人]
								</text>
								<text
									class="_text"
									v-else-if="userDetail.commentPolicy == 3">
									[你关注的人和已认证的人]
								</text>
								<text
									class="_text"
									v-else>
									[不允许所有人]
								</text>
							</view>
							<text class="iconfont icon-arrow-double-right"></text>
						</view>
					</view>
					<view class="user-operate-box-vertical">
						<!-- #ifdef MP-WEIXIN -->
						<view
							v-if="weChatBangDingStatus === 0"
							class="_for"
							@click="$_to('my/weChatBangDing')">
							<text class="iconfont icon-weixin" style="color: #67C23A;"></text>
							<view class="_for-c">
								<text class="text">微信绑定</text>
							</view>
							<text class="iconfont icon-arrow-double-right"></text>
						</view>
						<!-- #endif -->
						<!-- <view class="_for" @click="cliclSwitchLanguageButton">
							<text class="iconfont icon-Translate" style="color: #53bcf5;"></text>
							<view class="_for-c">
								<text class="text">{{$t('switchLanguage')}}</text>
							</view>
							<text class="iconfont icon-arrow-double-right"></text>
						</view> -->
						<!-- <view class="_for">
							<text class="iconfont icon-prompt" style="color: #a8c500;"></text>
							<view class="_for-c">
								<text class="text">{{$t('about')}}</text>
							</view>
							<text class="iconfont icon-arrow-double-right"></text>
						</view> -->
						<!-- #ifdef APP-PLUS -->
						<view class="_for" @click="$_to('my/checkVersion')">
							<text class="iconfont icon-shangchuan" style="color: #ff705e;"></text>
							<view class="_for-c">
								<text class="text">{{$t('checkVersion')}}</text>
								<view class="prompt" v-if="checkVersion"></view>
							</view>
							<text class="iconfont icon-arrow-double-right"></text>
						</view>
						<!-- #endif -->
						<view class="_for" @click="clickClearCacheButton">
							<text class="iconfont icon-fullscreen-shrink" style="color: #00c5c6;"></text>
							<view class="_for-c">
								<text class="text">清空缓存</text>
							</view>
							<text class="iconfont icon-arrow-double-right"></text>
						</view>
						<view class="_for" @click="clickLeaveButton">
							<text class="iconfont icon-cry" style="color: #dd0000;"></text>
							<view class="_for-c">
								<text class="text">{{$t('leave')}}</text>
							</view>
							<text class="iconfont icon-arrow-double-right"></text>
						</view>
					</view>
				</template>
				<template v-else>
					<view style="width: 100%;height: 100vh;display: flex;align-items: center;justify-content: center;">
						<global-loading></global-loading>
					</view>
				</template>
			</template>
			<template v-else>
				<view class="no-login" :style="globalJSON.userCenter.topStyle">
					<view class="no-login-box">
						<view class="no-login-box-title">
							<text>{{copyright?copyright.site_name:''}}</text>
						</view>
						<view class="no-login-box-login-button">
							<view
								@click="$_to('pages/loginOrRegister')"
								class="no-login-box-login-button-top">
								<view class="__input">{{$t('pleaseEnter')}}{{$t('emailOrPhone')}}</view>
								<view class="__input">{{$t('pleaseEnter')}}{{$t('accountPassword')}}</view>
								<view class="__button">{{$t('accountLogin')}} {{$t('modifierOr')}} {{$t('accountRegister')}}</view>
							</view>
							<!-- #ifdef MP-WEIXIN -->
							<view class="__and">
								<view></view>
								<text>{{$t('modifierOr')}}</text>
								<view></view>
							</view>
							<view
								@click="$_to('my/weChatLogin')"
								class="no-login-box-login-button-bottom">
								<view>
									<text class="iconfont icon-weixin1"></text>
									<text class="__text">微信快速登录</text>
								</view>
							</view>
							<!-- #endif -->
						</view>
					</view>
				</view>
			</template>
		</template>
		<template v-else>
			<view style="width: 100%;height: 100vh;display: flex;align-items: center;justify-content: center;">
				<global-loading></global-loading>
			</view>
		</template>
		
		<!-- 全客户端只此一处版权，请勿删除 -->
		<view class="copyright" v-if="copyright">
			<view
				class="copyright-for"
				v-if="copyright.account_terms_status||copyright.account_privacy_status||copyright.account_cookie_status||copyright.account_delete_status">
				<view
					@click="clickCopyrightButton('account_terms_status')"
					v-if="copyright.account_terms_status">服务条款</view>
				<view
					@click="clickCopyrightButton('account_privacy_status')"
					v-if="copyright.account_privacy_status">隐私政策</view>
				<view
					@click="clickCopyrightButton('account_cookie_status')"
					v-if="copyright.account_cookie_status">Cookie使用条款</view>
				<view
					@click="clickCopyrightButton('account_delete_status')"
					v-if="copyright.account_delete_status">注销说明</view>
			</view>
			<view class="copyright-for">© CopyRight {{copyright.site_copyright_name}} All Rights Reserved</view>
			<view class="copyright-for">Powered by Youransns and Fresns. Apache License Version 2.0</view>
		</view>
		<!-- 修改头像 -->
		<view v-if="avatarBox" class="global-bottom-to-top-pop-up">
			<view class="_top" @click="avatarBox = false"></view>
			<view class="_bottom">
				<view class="_title">
					<text class="_title-text">{{$t('modifyAvatar')}}</text>
					<view @click="avatarBox = false"><text class="iconfont icon-close-bold"></text></view>
				</view>
				<view class="global-bottom-to-top-pop-up-avatar">
					<view class="_add">
						<view class="_add-button" @click="clickAvatarChooseImageButton">
							<template v-if="avatarBoxImage">
								<image :src="avatarBoxImage" mode="widthFix"></image>
							</template>
							<template v-else>
								<text class="iconfont icon-add-bold"></text>
							</template>
						</view>
						<view
							class="_add-upload-button"
							v-if="avatarBoxImage"
							@click="clickAvatarUploadButton">
							{{$t('confirm')}}
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 修改昵称 -->
		<view v-if="nicknameBox" class="global-bottom-to-top-pop-up">
			<view class="_top" @click="nicknameBox = false"></view>
			<view class="_bottom">
				<view class="_title">
					<text class="_title-text">{{$t('modifyNickname')}}</text>
					<view @click="nicknameBox = false"><text class="iconfont icon-close-bold"></text></view>
				</view>
				<view class="global-bottom-to-top-pop-up-nickname">
					<view class="_box">
						<input type="text" v-model="nicknameBoxContent"/>
						<view @click="clickNicknameButton">{{$t('confirm')}}</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 修改 banner 图 -->
		<view v-if="bannerBox" class="global-bottom-to-top-pop-up">
			<view class="_top" @click="bannerBox = false"></view>
			<view class="_bottom">
				<view class="_title">
					<text class="_title-text">{{$t('modifyBanner')}}</text>
					<view @click="bannerBox = false"><text class="iconfont icon-close-bold"></text></view>
				</view>
				<view class="global-bottom-to-top-pop-up-banner">
					<view class="_add">
						<view class="_add-button" @click="clickBannerChooseImageButton">
							<template v-if="bannerBoxImage">
								<image :src="bannerBoxImage" mode="widthFix"></image>
							</template>
							<template v-else>
								<text class="iconfont icon-add-bold"></text>
							</template>
						</view>
						<view
							class="_add-upload-button"
							v-if="bannerBoxImage"
							@click="clickBannerUploadButton">
							{{$t('confirm')}}
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 修改用户简介 -->
		<view v-if="bioBox" class="global-bottom-to-top-pop-up">
			<view class="_top" @click="bioBox = false"></view>
			<view class="_bottom">
				<view class="_title">
					<text class="_title-text">{{$t('modifyBio')}}</text>
					<view @click="bioBox = false"><text class="iconfont icon-close-bold"></text></view>
				</view>
				<view class="global-bottom-to-top-pop-up-bio">
					<view class="_box">
						<textarea
							maxlength="-1"
							v-model="bioBoxContent"></textarea>
						<view @click="clickBioButton">{{$t('confirm')}}</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 修改用户位置 -->
		<view v-if="locationBox" class="global-bottom-to-top-pop-up">
			<view class="_top" @click="locationBox = false"></view>
			<view class="_bottom">
				<view class="_title">
					<text class="_title-text">{{$t('modifyLocation')}}</text>
					<view @click="locationBox = false"><text class="iconfont icon-close-bold"></text></view>
				</view>
				<view class="global-bottom-to-top-pop-up-bio">
					<view class="_box">
						<textarea
							maxlength="-1"
							v-model="locationBoxContent"></textarea>
						<view @click="clickLocationButton">{{$t('confirm')}}</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 版权 -->
		<view v-if="copyrightBox" class="global-bottom-to-top-pop-up">
			<view class="_top" @click="copyrightBox = false"></view>
			<view class="_bottom">
				<view class="_title">
					<text class="_title-text">{{copyrightTitle}}</text>
					<view @click="copyrightBox = false"><text class="iconfont icon-close-bold"></text></view>
				</view>
				<view class="global-bottom-to-top-pop-up-copyrightContent">
					<scroll-view scroll-y>
						<mp-html
							:content="copyrightContent"
							:selectable="true"/>
					</scroll-view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isLogin:false,
				userDetail:null,
				userUid:null,
				globalJSON:null,
				
				copyright:null,
				copyrightBox:false,
				copyrightContent:"",
				copyrightTitle:"",
				
				avatarBox:false,
				avatarBoxImage:"",
				
				
				bannerBox:false,
				bannerBoxImage:"",
				
				nicknameBox:false,
				nicknameBoxContent:"",
				
				bioBox:false,
				bioBoxContent:"",
				
				locationBox:false,
				locationBoxContent:"",
				
				checkVersion:false,//是否APP有更新
				
				weChatBangDingStatus:0,
			}
		},
		onShow() {
			setTimeout(()=>{
				if (uni.getStorageSync('accountAuthToken')) {
					this.isLogin = true
				} else {
					this.isLogin = false
				}
				if(this.$_isLogin()){
					// 是否有未读
					this.$_isNotification();
					this.userUid = JSON.parse(uni.getStorageSync('accountAuthToken')).uid;
					this.getUser();
				}
			},200);
		},
		onLoad() {
			// app 检查更新
			// #ifdef APP-PLUS
			uni.request({
				url:this.$_configFile() + "checkVersion.json",
				method:"GET",
				success: (res) => {
					if(res.data.latestVersion == plus.runtime.version){
						this.checkVersion = false;
					}else{
						this.checkVersion = true;
					}
				}
			})
			// #endif
			this.getGlobalJSON();
			// 版权
			this.$_request(
				"GET","/api/fresns/v1/global/configs",
				{
					"keys":"site_copyright_name,site_copyright_years,site_name,site_url,account_terms_status,account_privacy_status,account_cookie_status,account_delete_status,account_terms_policy,account_privacy_policy,account_cookie_policy,account_delete_policy"
				},
				(res) => {
					this.copyright = res.data.data;
				}
			)
		},
		methods: {
			getGlobalJSON(){
				uni.request({
					url:this.$_configFile() + "global.json",
					method:"GET",
					success: (res) => {
						this.globalJSON = res.data;
					}
				})
			},
			getUser(){
				this.$_request(
					"GET",`/api/fresns/v1/user/${this.userUid}/detail`, {},
					(res) => {
						this.userDetail = res.data.data.detail;
						this.nicknameBoxContent = this.userDetail.nickname;
						this.bioBoxContent = this.userDetail.bio;
						this.locationBoxContent = this.userDetail.location;
						// #ifdef MP-WEIXIN
						this.getAccountDetail();
						// #endif
					}
				)
			},
			// 用于检查是否绑定了微信
			getAccountDetail(){
				this.$_request(
					"GET","/api/fresns/v1/account/detail",{},
					(res) => {
						res.data.data.detail.connects.forEach((item, i) => {
							if (item.connectPlatformId == 25) {
								if(item.connected){
									this.weChatBangDingStatus = 1;
								}else{
									this.weChatBangDingStatus = 0;
								}
								return;
							}
						})
					}
				)
			},
			// 修改头像按钮
			clickAvatarChooseImageButton(){
				uni.chooseImage({
					count:1,
					success: (res) => {
						this.avatarBoxImage = res.tempFiles[0].path;
					}
				})
			},
			// 确认上传头像
			clickAvatarUploadButton(){
				const _this = this;
				uni.showLoading();
				uni.uploadFile({
					url: _this.$_url() + "/api/fresns/v1/common/file/upload",
					filePath: _this.avatarBoxImage,
					name: "file",
					header: _this.$_fresnsHeader(),
					formData:{
						"usageType": "userAvatar",
						"usageFsid": _this.userUid,
						"type":"image"
					},
					success(res) {
						_this.avatarBox = false;
						_this.avatarBoxImage = "";
						uni.hideLoading();
						if(JSON.parse(res.data).code == 0){
							_this.getUser();
						}else{
							uni.showToast({
								title: JSON.parse(res.data).message,
								icon: 'none',
								duration: 1000
							});
						}
					}
				})
			},
			// 确认修改昵称
			clickNicknameButton(){
				uni.showLoading();
				this.$_request(
					"PATCH","/api/fresns/v1/user/profile",
					{
						"nickname":this.nicknameBoxContent
					},
					(res) => {
						uni.hideLoading();
						this.nicknameBox = false;
						if(res.data.code === 0){
							this.getUser();
						}else{
							uni.showToast({
								title: res.data.message,
								icon: 'none',
								duration: 1000
							});
						}
					}
				)
			},
			// 修改banner按钮
			clickBannerChooseImageButton(){
				uni.chooseImage({
					count:1,
					success: (res) => {
						this.bannerBoxImage = res.tempFiles[0].path;
					}
				})
			},
			// 确认上传banner
			clickBannerUploadButton(){
				const _this = this;
				uni.showLoading();
				uni.uploadFile({
					url: _this.$_url() + "/api/fresns/v1/common/file/upload",
					filePath: _this.bannerBoxImage,
					name: "file",
					header: _this.$_fresnsHeader(),
					formData:{
						"usageType": "userBanner",
						"usageFsid": _this.userUid,
						"type":"image"
					},
					success(res) {
						_this.bannerBox = false;
						_this.bannerBoxImage = "";
						uni.hideLoading();
						if(JSON.parse(res.data).code == 0){
							_this.getUser();
						}else{
							uni.showToast({
								title: JSON.parse(res.data).message,
								icon: 'none',
								duration: 1000
							});
						}
					}
				})
			},
			// 修改性别
			clickGenderButton(){
				uni.showActionSheet({
					itemList: [this.$t('settingGenderMale'),this.$t('settingGenderFemale'), this.$t('settingGender')],
					success: (res) => {
						if(res.tapIndex === 0){
							this.patchGender(2)
						}
						if(res.tapIndex === 1){
							this.patchGender(3)
						}
						if(res.tapIndex === 2){
							this.patchGender(1)
						}
					}
				});
			},
			// 修改性别方法
			patchGender(type){
				uni.showLoading();
				this.$_request(
					"PATCH","/api/fresns/v1/user/profile",
					{
						"gender":type
					},
					(res) => {
						uni.hideLoading();
						if(res.data.code === 0){
							this.getUser();
						}else{
							uni.showToast({
								title: res.data.message,
								icon: 'none',
								duration: 1000
							});
						}
					}
				)
			},
			// 修改用户简介
			clickBioButton(){
				uni.showLoading();
				this.$_request(
					"PATCH","/api/fresns/v1/user/profile",
					{
						"bio":this.bioBoxContent
					},
					(res) => {
						uni.hideLoading();
						this.bioBox = false;
						if(res.data.code === 0){
							this.getUser();
						}else{
							uni.showToast({
								title: res.data.message,
								icon: 'none',
								duration: 1000
							});
						}
					}
				)
			},
			// 修改用户位置
			clickLocationButton(){
				uni.showLoading();
				this.$_request(
					"PATCH","/api/fresns/v1/user/profile",
					{
						"location":this.locationBoxContent
					},
					(res) => {
						uni.hideLoading();
						this.locationBox = false;
						if(res.data.code === 0){
							this.getUser();
						}else{
							uni.showToast({
								title: res.data.message,
								icon: 'none',
								duration: 1000
							});
						}
					}
				)
			},
			// 切换语言
			cliclSwitchLanguageButton(){
				uni.showActionSheet({
					itemList: ["中文简体","中文繁體","English"],
					success: (res) => {
						if(res.tapIndex === 0){
							uni.setLocale('zh-Hans');
						}
						if(res.tapIndex === 1){
							uni.setLocale('zh-Hant');
						}
						if(res.tapIndex === 2){
							uni.setLocale('en');
						}
					}
				});
			},
			// 退出
			clickLeaveButton(){
				uni.showModal({
					title: this.$t('leave') + '?',
					success: (res) => {
						if(res.confirm){
							uni.removeStorageSync('accountAuthToken');
							this.userDetail = null;
							this.isLogin = false;
						}
					}
				});
			},
			// 点击清空缓存按钮
			clickClearCacheButton(){
				uni.showModal({
					title: '提示',
					content: '是否清空缓存？',
					success: (res) => {
						if (res.confirm) {
							uni.removeStorageSync('diy_1_json');
							uni.removeStorageSync('diy_2_json');
							uni.removeStorageSync('diy_3_json');
							uni.removeStorageSync('post_json');
							uni.switchTab({
								url:"/pages/navigation/diy_1"
							})
						}
					}
				});
			},
			// 点击版权
			clickCopyrightButton(type){
				this.copyrightBox = true;
				if(type == 'account_terms_status'){
					this.copyrightContent = this.copyright.account_terms_policy;
					this.copyrightTitle = "服务条款";
				}
				if(type == 'account_privacy_status'){
					this.copyrightContent = this.copyright.account_privacy_policy;
					this.copyrightTitle = "隐私政策";
				}
				if(type == 'account_cookie_status'){
					this.copyrightContent = this.copyright.account_cookie_policy;
					this.copyrightTitle = "Cookie使用条款";
				}
				if(type == 'account_delete_status'){
					this.copyrightContent = this.copyright.account_delete_policy;
					this.copyrightTitle = "注销说明";
				}
			},
			// 点击，对话设置
			clickConversationPolicyButton(){
				uni.showActionSheet({
					itemList: ['所有人', '你关注的人', '你关注的人和已认证的人', '不允许所有人'],
					success: (res) => {
						let _data = 1;
						if(res.tapIndex == 0){ _data = 1; }
						if(res.tapIndex == 1){ _data = 2; }
						if(res.tapIndex == 2){ _data = 3; }
						if(res.tapIndex == 3){ _data = 4; }
						this.$_request(
							"PATCH","/api/fresns/v1/user/setting",
							{
								"conversationPolicy":_data
							},
							(ref) => {
								if(ref.data.code == 0){
									uni.showToast({
										title: '修改成功',
										duration: 1500,
										icon:'none'
									});
									this.getUser();
								}else{
									uni.showToast({
										title: ref.data.message,
										duration: 1500,
										icon:'none'
									});
								}
							}
						)
						
						
					}
				});
			},
			// 点击，评论设置
			clickCommentPolicyButton(){
				uni.showActionSheet({
					itemList: ['所有人', '你关注的人', '你关注的人和已认证的人', '不允许所有人'],
					success: (res) => {
						let _data = 1;
						if(res.tapIndex == 0){ _data = 1; }
						if(res.tapIndex == 1){ _data = 2; }
						if(res.tapIndex == 2){ _data = 3; }
						if(res.tapIndex == 3){ _data = 4; }
						this.$_request(
							"PATCH","/api/fresns/v1/user/setting",
							{
								"commentPolicy":_data
							},
							(ref) => {
								if(ref.data.code == 0){
									uni.showToast({
										title: '修改成功',
										duration: 1500,
										icon:'none'
									});
									this.getUser();
								}else{
									uni.showToast({
										title: ref.data.message,
										duration: 1500,
										icon:'none'
									});
								}
							}
						)
						
						
					}
				});
			},
		}
	}
</script>

<style lang="scss">
.my{
	.no-login{
		background: $theme;
		width: 100%;
		height:calc(100vh - var(--window-top) - var(--window-bottom));
		display: flex;
		align-items: center;
		justify-content: center;
		position: fixed;
		z-index: 999;
		left: 0;
		top: 0;
		.no-login-box{
			width: 600rpx;
			border-radius: 15rpx;
			.no-login-box-title{
				line-height: 60rpx;
				text-align: center;
				text{
					font-size: 60rpx;
					color: #FFF;
					font-weight: bold;
					font-style: italic;
					text-shadow: 0 0 1px #000;
				}
			}
			.no-login-box-login-button{
				background-color:rgba(0,0,0,0.3);
				border-radius: 15rpx;
				margin-top: 50rpx;
				padding: 50rpx 50rpx 30rpx 50rpx;
				.__and{
					display: flex;
					align-items: center;
					justify-content: center;
					line-height: 22rpx;
					margin-top: 30rpx;
					view{
						flex: 1;
						height: 1px;
						background: #FFF;
						opacity: .5;
					}
					text{
						flex-shrink: 0;
						color: #FFF;
						font-size: 22rpx;
						padding: 0 15rpx;
					}
				}
				.no-login-box-login-button-top{
					.__input{
						width: 100%;
						height: 80rpx;
						background: #FFF;
						margin-bottom: 25rpx;
						border-radius: 10rpx;
						display: flex;
						align-items: center;
						justify-content: center;
						font-size: 28rpx;
						color: $placeholder;
					}
					.__button{
						width: 100%;
						height: 80rpx;
						font-size: 28rpx;
						background: $theme;
						border-radius: 10rpx;
						display: flex;
						align-items: center;
						justify-content: center;
						color: #FFF;
					}
				}
				.no-login-box-login-button-bottom{
					display: flex;
					align-items: center;
					justify-content: center;
					margin-top: 30rpx;
					view{
						line-height: 60rpx;
						display: flex;
						align-items: center;
						justify-content: center;
						border-radius: 10rpx;
						background: #FFF;
						line-height: 40rpx;
						padding: 17rpx 25rpx 15rpx 25rpx;
						.iconfont{
							font-size: 40rpx;
							color: $green;
							padding-right: 15rpx;
						}
						.__text{
							font-size: 22rpx;
						}
					}
				}
			}
		}
	}
	.copyright{
		display: flex;
		align-items: center;
		justify-content: center;
		flex-flow: column;
		padding-bottom: 15rpx;
		.copyright-for{
			font-size: 18rpx;
			line-height: 18rpx;
			color: $placeholder;
			text-shadow: 0 0 2px #FFF;
			padding-bottom: 10rpx;
			display: flex;
			align-items: center;
			view{
				font-size: 18rpx;
				padding: 0 5rpx;
			}
		}
	}
	.user-top{
		width: 100%;
		min-height: 375rpx;
		.user-detail{
			width: 100%;
			padding-top: 150rpx;
			.user-detail-top{
				display: flex;
				align-items: center;
				padding: 0 50rpx;
				._avatar{
					width: 120rpx;
					height: 120rpx;
					overflow: hidden;
					flex-shrink: 0;
					border-radius: 100rpx;
					border: 5rpx solid #FFF;
					box-shadow: 0 0 2px #000;
				}
				._center{
					flex: 1;
					margin-left: 25rpx;
					._nickname{
						font-size: 50rpx;
						line-height: 50rpx;
						font-weight: bold;
						color: #FFF;
						text-shadow: 0 0 2px #000;
					}
					._user-count{
						display: flex;
						align-items: center;
						margin-top: 15rpx;
						._for{
							color: #FFF;
							text-shadow: 0 0 2px #000;
							border-right: 1px solid #FFF;
							line-height: 28rpx;
							font-size: 28rpx;
							padding-right: 25rpx;
							margin-right: 25rpx;
						}
						._for:last-child{
							border-right: 0;
							padding-right: 0;
							margin-right: 0;
						}
					}
				}
			}
		}
		.user-bio{
			padding: 50rpx;
			color: #FFF;
			text-shadow: 0 0 2px #000;
		}
	}
	.user-operate-box-horizontal{
		background: #FFF;
		margin-bottom: 25rpx;
		display: flex;
		flex-wrap: wrap;
		._for{
			width: 25%;
			display: flex;
			align-items: center;
			justify-content: center;
			flex-flow: column;
			border: .5px solid $background;
			box-sizing: border-box;
			padding: 25rpx 0;
			.iconfont{
				display: flex;
				align-items: center;
				justify-content: center;
				font-size: 55rpx;
				line-height: 55rpx;
			}
			.text{
				display: flex;
				align-items: center;
				justify-content: center;
				font-size: 22rpx;
				line-height: 22rpx;
				padding-top: 10rpx;
			}
		}
	}
	.user-operate-box-vertical{
		background: #FFF;
		padding: 0 25rpx;
		margin-bottom: 25rpx;
		._for{
			display: flex;
			align-items: center;
			border-bottom: 1px solid $background;
			padding: 25rpx 0;
			.iconfont{
				display: flex;
				align-items: center;
				font-size: 40rpx;
				line-height: 40rpx;
			}
			._for-c{
				display: flex;
				align-items: center;
				padding-left: 15rpx;
				flex: 1;
				.text{
					display: flex;
					align-items: center;
					font-size: 28rpx;
					line-height: 28rpx;
				}
				._text{
					display: flex;
					align-items: center;
					font-size: 22rpx;
					padding-left: 15rpx;
					color: $placeholder;
				}
				.prompt{
					width: 15rpx;
					height: 15rpx;
					background: $red;
					border-radius: 100rpx;
					margin-left: 10rpx;
				}
			}
			.icon-arrow-double-right{
				display: flex;
				align-items: center;
				font-size: 28rpx;
				line-height: 28rpx;
				color: $placeholder;
			}
		}
		._for:last-child{
			border-bottom: 0;
		}
	}
}
.global-bottom-to-top-pop-up-avatar{
	._add{
		display: flex;
		align-items: center;
		justify-content: center;
		padding: 50rpx;
		flex-flow: column;
		._add-button{
			width: 200rpx;
			height: 200rpx;
			overflow: hidden;
			display: flex;
			align-items: center;
			justify-content: center;
			border: 1px solid $border;
			border-radius: 100%;
			line-height: 50rpx;
			text{
				font-size: 50rpx;
			}
		}
		._add-upload-button{
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 28rpx;
			line-height: 28rpx;
			padding-top: 25rpx;
		}
	}
}
.global-bottom-to-top-pop-up-banner{
	._add{
		display: flex;
		align-items: center;
		justify-content: center;
		padding: 50rpx;
		flex-flow: column;
		._add-button{
			width: 200rpx;
			height: 200rpx;
			overflow: hidden;
			display: flex;
			align-items: center;
			justify-content: center;
			border: 1px solid $border;
			border-radius: 100%;
			line-height: 50rpx;
			text{
				font-size: 50rpx;
			}
		}
		._add-upload-button{
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 28rpx;
			line-height: 28rpx;
			padding-top: 25rpx;
		}
	}
}
.global-bottom-to-top-pop-up-nickname{
	._box{
		display: flex;
		align-items: center;
		padding: 50rpx;
		input{
			background: $background;
			flex: 1;
			flex-shrink: 0;
			height: 60rpx;
			text-align: center;
			font-size: 28rpx;
		}
		view{
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 28rpx;
			line-height: 28rpx;
			background: $theme;
			height: 60rpx;
			padding: 0 25rpx;
			color: #FFF;
		}
	}
}
.global-bottom-to-top-pop-up-bio{
	._box{
		display: flex;
		align-items: center;
		padding: 50rpx;
		textarea{
			background: $background;
			flex: 1;
			flex-shrink: 0;
			height: 150rpx;
			font-size: 28rpx;
			margin-right: 10rpx;
		}
		view{
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 28rpx;
			line-height: 28rpx;
			background: $theme;
			height: 60rpx;
			padding: 0 25rpx;
			color: #FFF;
		}
	}
}
.global-bottom-to-top-pop-up-copyrightContent{
	padding: 25rpx;
	scroll-view{
		max-height: 700rpx;
	}
}
</style>